{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import torch\n",
    "import torch.nn.functional as F"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "torch.Size([88, 19, 93, 25])"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "input = torch.randn(88,66,99,33)\n",
    "weight = torch.randn(19,66,7,9)\n",
    "bias = torch.empty(19).normal_()\n",
    "output = F.conv2d(input,weight,bias)\n",
    "output.size()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "torch.Size([88, 19, 93, 25])\n"
     ]
    }
   ],
   "source": [
    "input = torch.randn(88,66,99,33)\n",
    "weight = torch.randn(19,66,7,9)\n",
    "bias = torch.empty(19).normal_()\n",
    "conv2d = torch.nn.Conv2d(in_channels=66,out_channels=19,kernel_size=(7,9))\n",
    "print(conv2d(input).size())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "torch.Size([88, 19, 32, 8])\n"
     ]
    }
   ],
   "source": [
    "#指定Stride=3，padding=1\n",
    "input = torch.randn(88,66,99,33)\n",
    "conv2d = torch.nn.Conv2d(in_channels=66,out_channels=19,kernel_size=(7,14),stride=3,padding=1)\n",
    "print(conv2d(input).size())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "torch.Size([88, 19, 30, 3])\n",
      "torch.Size([88, 19, 10, 1])\n"
     ]
    }
   ],
   "source": [
    "#指定Stride=3,padding=1,dilation=2\n",
    "input = torch.randn(88,66,99,33)\n",
    "conv2d = torch.nn.Conv2d(in_channels=66,out_channels=19,kernel_size=(7,14),stride=3,padding=1,dilation=2)\n",
    "maxpool = torch.nn.MaxPool2d((3,2))\n",
    "print(conv2d(input).size())\n",
    "print(maxpool(conv2d(input)).size())"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
